<template>
    <div>
        <h2 style="margin-left: 15px">{{title}}</h2>
        <div class="edit">
            <quill-editor
                    v-model="detailContent"
                    :options="editorOption"
                    style="height: 200px;"
                    @focus="editorFocus($event)"
            >
            </quill-editor>
        </div>
        <div class="fujian display-row" style="margin-top: 80px;">
            <el-table
                    :data="attachment"
                    @row-click="clickrow"
                    :row-style="{cursor:'pointer'}"
                    style="width: 100%">
                <el-table-column
                        prop="filename"
                        label="附件（点击可下载）">
                </el-table-column>
            </el-table>
        </div>
    </div>

</template>

<script>
    import API from "../../../api";

    export default {
        name: "ph_notify_detail",
        props:{
            infoid:'',
            /**
             * 0： 通知
             * 1： 征集
             */
            showType: {
                type: Number,
                default: 0,
            }
        },
        data(){
            return{
                title:'',
                detailContent:'',
                attachment: [],//该条详情的附件
                editorOption: {
                    placeholder: '',
                    theme: 'bubble',  // or 'bubble'
                    modules: {
                        toolbar: null
                    }
                },
            }
        },

        methods:{
            setNotifyData(){
                let data ={
                    token: this.token,
                    query_id : this.infoid
                }
                console.log(">>>")
                console.log(this.infoid)
                API.readNotify(data).then(res => {
                    if (res.code) {
                        alert(res.message);
                        return;
                    }
                    if (res.type === 1) {
                        this.title = res.title
                        this.detailContent = res.content
                        this.attachment = res.attachment
                        // res.range.forEach(item => {
                        //     this.notifyRange = this.notifyRange + item.userInfo.name + ' '
                        // })
                    } else {
                        this.title = res.title
                        this.detailContent = res.content
                    }
                })
            },
            setZhengjiData(data){
                this.title = data.name;
                this.detailContent = data.requirement;
                this.attachment = data.attachment;
            },
            editorFocus(qevent){
                qevent.enable(false)
            },
            clickrow(row, event, column){
                window.open(row.url)
            },
        },
        mounted:function(){
            console.log("这个在edit页面应该第二个出现"+this.infoid)
            if (this.showType === 0) {
                this.setNotifyData()
            }
        },
    }
</script>

<style scoped>
    .edit{
        margin-left: 10px;
        margin-right: 10px;
        margin-top: 5px;
    }

</style>
